#include <vector>
#include <string>
#include <unordered_map>
#include <iostream>
#include <time.h>
using namespace std;
class Solution
{
public:
    string countAndSay(int n)
    {
        // cout << n << endl;
        string ans, tmp;
        if (n > 1)
            tmp = countAndSay(n - 1);
        else
            return "1";
        // cout << tmp << endl;
        char pre = 0;
        int num = 0;
        for (auto e : tmp)
        {
            // cout << e << endl;
            if (pre && e != pre)
            {
                // cout << pre << num << endl;
                ans += to_string(num);
                ans += pre;
                num = 1;
            }
            else
                ++num;
            pre = e;
        }
        // cout << pre << endl;
        ans += to_string(num);
        ans += pre;
        // reverse(ans.begin(), ans.end());
        return ans;
    }
};